<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body,dl,dt,dd,h3{
            margin:0;
            padding:0;
        }
        .main{
            width: 250px;
            margin:40px auto;
            
        }
        .main h3{
            background: #f60;
            font-weight: normal;
            color: #fff;
            text-align: center;
            line-height: 40px;
            
        }
        .main dl{
            border:1px solid #c6c6c6;
            border-top: 0;
            padding: 15px 0;

        }
        .main dt{
            background: #e6e6e6;
            padding: 0 15px;

        }
        .main dd{
            box-sizing: border-box;
            overflow: hidden;
            display: none;
           
            
        }
        .main a{
            display:block;
            text-decoration: none;
            color: #333;
            background: #fff;
            padding: 5px 25px;
            line-height: 30px;
            font-size:14px;
        }
        .main a:hover{
            color: #f60;
        }
        .main span{
            float: right;
            background: #fff;
            text-align: center;
            line-height:18px;
            width: 16px;
            height:16px;
            margin: 2px 0;
        }


       
    </style>
</head>

<body>
    <div class="main">
    <h3>食品饮料分类</h3>
    <dl>
        <dt>进口食品<span>+</span></dt>
        <dd>
            <a href="#">进口的牛奶</a>
            <a href="#">进口的巧克力</a>
            <a href="#">进口黄油</a>
        </dd>
        <dt>休闲食品<span>+</span></dt>
        <dd>
            <a href="#">薯片</a>
            <a href="#">麦丽素</a>
            <a href="#">方便面</a>
        </dd>
        <dt>茶叶<span>+</span></dt>
        <dd>
            <a href="#">绿茶</a>
            <a href="#">红茶</a>
            <a href="#">普洱茶</a>
        </dd>
        <dt>饮料<span>+</span></dt>
        <dd>
            <a href="#">可乐</a>
            <a href="#">苏打水</a>
            <a href="#">果汁</a>
        </dd>
        <dt>酒水<span>+</span></dt>
        <dd>
            <a href="#">啤酒</a>
            <a href="#">红酒</a>
            <a href="#">伏特加</a>
        </dd>
        <dt>粮油<span>+</span></dt>
        <dd>
            <a href="#">大米</a>
            <a href="#">菜籽油</a>
            <a href="#">面粉</a>
        </dd>
        <dt>水果<span>+</span></dt>
        <dd>
            <a href="#">苹果</a>
            <a href="#">橘子</a>
            <a href="#">香蕉</a>
        </dd>
        
    </dl>
    </div>
    <script src="js/jquery.js"></script>
    <script>
        //设置点击事件
        $('.main').on('click','dt',function(){
            //电极式先关闭其他兄弟元素
            $('dt').next().slideUp()
            //将点击的dt下一个兄弟元素下来
            $(this).next().stop().slideDown(1000)
            //除点击元素外的子元素全部变为+号
            $('dt').children().html('+')
            //被点击的元素子元素变为减号
            $(this).children().html('-')
                
            
        });

     
    </script>

</body>

</html>